﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace SpotifyRemote
{
	public partial class Main : Form
	{
		public Main()
		{
			InitializeComponent();
		}

		Server _Server;

		private void Main_Load(object sender, EventArgs e)
		{
			_Server = new Server();
			bStartStop_Click(null, null);
		}

		private void Main_FormClosing(object sender, FormClosingEventArgs e)
		{
			_Server.Stop();
		}

		private void bStartStop_Click(object sender, EventArgs e)
		{
			if (_Server.IsRunning)
			{
				_Server.Stop();
				bStartStop.Text = "Start";
			}
			else
			{
				_Server.Start((int)Math.Floor(Properties.Settings.Default.Port));
				bStartStop.Text = "Stop";
			}
		}

		private void bTest_Click(object sender, EventArgs e)
		{
			System.Diagnostics.Process.Start("http://localhost:" + Properties.Settings.Default.Port + "/");
		}
	}
}
